<%@page contentType="text/html" pageEncoding="UTF-8" import="java.io.*, java.sql.*, javax.sql.*"%>

<%
    try {
        String id = request.getParameter("id");
        if (id == null) {
            return;
        }
        Connection con = com.elookinto.wordlist.Util.getCon();
        PreparedStatement st = null;
        String note = null;
        String comment = request.getParameter("comment");
        String user = request.getParameter("user");
        if (user == null) {
            user = request.getRemoteHost();
        }
        if (comment != null) {
            st = con.prepareStatement("insert into comment (comment,user_, id, insert_time) values (?, ?, ?, current_timestamp)");
            st.setString(1, comment);
            st.setString(2, user);
            st.setString(3, id);
            st.executeUpdate();
        }
        
        st = con.prepareStatement("select comment,insert_time,user_ from comment where id = ? order by insert_time ");
        st.setString(1, id);
        ResultSet rs = st.executeQuery();
        int i = 0;
        java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy.MM.dd");
        while (rs.next()) {
              comment = rs.getString("comment");
             user = rs.getString("user_");
            Date d = null;
            if (rs.getTimestamp("insert_time") != null) {
                d = new Date(rs.getTimestamp("insert_time").getTime());
            }

            i++;
            if (comment == null) {
                continue;
            }

%>
By <%= user%> - <%= d%> <br/>
<p style="margin-bottom: 3px;"> &nbsp;&nbsp; <%=comment%></p>

<%}
       
        rs.close();
        st.close();
        con.close();
    } catch (Exception e) {
        out.println(e.getMessage());
    }
%>


<%--

create table comment (id varchar(36), user_ varchar(30), comment varchar(1000), insert_time timestamp);

--%>